Retrieving a Result Set Using a DataAdapter Object
The DataAdapter is a bridge between the ADO.NET DataSet object and the underlying DBMS. The DataAdapter can be used to fill a DataSet with a result set or multiple result sets. Although the DataAdapter also includes functionality to propagate changes to the result set back to the DBMS, this example only shows how to set up the DataAdapter to retrieve the data and Fill a DataSet.
NOTE: The example requires the emp table (see "Sample Tables for Sybase"). The Sybase database in this example does not require the Database connection string option.
// Open connection to SequeLink Server on Sybase database SequeLinkConnection Conn; Conn = new SequeLinkConnection("host=bowhead;port=19996;User ID=test01; Password=test01"); Conn.Open(); // Create a SQL command string sqlSEL = "SELECT NAME FROM emp WHERE sal>'50000'"; SequeLinkDataAdapter myDataAdapter = new SequeLinkDataAdapter(sqlSEL, Conn); DataSet myDataSet = new DataSet("salDataSet"); try { myDataAdapter.Fill(myDataSet, "emp"); } catch(Exception ex) { // Display any exceptions in a messagebox MessageBox.Show (ex.Message); } finally // Close the connection { Conn.Close(); }